lib: Add an "is_system" member to OstreeRepo
authorColin Walters <walters@verbum.org>
Thu, 25 May 2017 21:26:42 +0000 (17:26 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Fri, 26 May 2017 19:17:59 +0000 (19:17 +0000)
This is prep for introducing a fd-relative `ostree_repo_new_at()`.
Previously, `ostree_repo_is_system()` compared `GFile` paths, but
there's a much simpler check we can do first - if this repository
was created via `OstreeSysroot`, it must be a system repo.

Closes: #886
Approved by: jlebon

src/libostree/ostree-repo-private.h
src/libostree/ostree-repo.c
src/libostree/ostree-sysroot.c

index 7efbf91ff4c62f3dd7caa6ab025924575127a280..015a9a8bd83f2e0010fa5a9666c43e9f908dffab 100644 (file)
@@ -106,6 +106,7 @@ struct OstreeRepo {
 
   gboolean inited;
   gboolean writable;
+  gboolean is_system; /* Was this repo created via ostree_sysroot_get_repo() ? */
   GError *writable_error;
   gboolean in_transaction;
   gboolean disable_fsync;
index 7ee2c9aaec4d4da527a67d3e56e4a950389753a7..cbbaec9b0aaf99f7d5d35f87fd79410d4a851d2d 100644 (file)
@@ -710,6 +710,12 @@ ostree_repo_is_system (OstreeRepo   *repo)
 
   g_return_val_if_fail (OSTREE_IS_REPO (repo), FALSE);
 
+  /* If we were created via ostree_sysroot_get_repo(), we know the answer is yes
+   * without having to compare file paths.
+   */
+  if (repo->is_system)
+    return TRUE;
+
   default_repo_path = get_default_repo_path (repo->sysroot_dir);
 
   return g_file_equal (repo->repodir, default_repo_path);
index e47214c592f7bfda2505f5636cf06b3ffdcb29d1..ac24b0afc4d2a1b789094ae564f5c6d8e94f60e6 100644 (file)
@@ -26,6 +26,7 @@
 #include <sys/wait.h>
 
 #include "ostree-core-private.h"
+#include "ostree-repo-private.h"
 #include "ostree-sepolicy-private.h"
 #include "ostree-sysroot-private.h"
 #include "ostree-deployment-private.h"
@@ -133,6 +134,7 @@ ostree_sysroot_constructed (GObject *object)
 
   repo_path = g_file_resolve_relative_path (self->path, "ostree/repo");
   self->repo = ostree_repo_new_for_sysroot_path (repo_path, self->path);
+  self->repo->is_system = TRUE;
 
   G_OBJECT_CLASS (ostree_sysroot_parent_class)->constructed (object);
 }